/**
 * @file
 * @auth jinguangguo
 * @date 2016/10/17
 */

import path from 'path';

let webpack = require('webpack');
const PUBLIC_PATH = '/';

export default {
    entry: {
        'market': ['./src/js/market.js'],
        'index': ['./src/js/index.js'],
        'account': ['./src/js/account.js'],
        'register': ['./src/js/register.js'],
        'active': ['./src/js/active.js'],
        'login': ['./src/js/login.js'],
        'reset': ['./src/js/reset.js'],

        'notice': ['./src/js/notice.js'],
        'about': ['./src/js/about.js'],
        'c2c': ['./src/js/c2c.js'],

        'third': ['./src/js/third.js'],
        'recharge_usc': ['./src/js/recharge_usc.js'],
        'smc_finance': ['./src/js/smc_finance.js'],
        'invite': ['./src/js/invite.js'],

        'm_register': ['./src/js/m_register.js'],
        'm_login': ['./src/js/m_login.js'],
        'm_reset': ['./src/js/m_reset.js'],
        'fund': ['./src/js/fund.js'],
    },
    output: {
        path: path.resolve(__dirname, 'dev'),
        publicPath: PUBLIC_PATH,
        filename: 'js/[name].js'
    },
    module: {
        loaders: [
            {
                test: /\.(tpl|html)$/,
                loader: 'html'
            },
            {
                test: /\.css$/,
                loaders: [
                    'style-loader',
                    'css-loader?importLoaders=1',
                    'postcss-loader'
                ]
            },
            {
                test: /\.scss$/,
                loaders: [
                    'style-loader',
                    'css-loader?importLoaders=1',
                    'postcss-loader',
                    'sass-loader'
                ]
                // loaders: ["style", "css", "sass"]
            },
            {
                test: /\.js$/,
                loader: 'babel',
                exclude: /node_modules/,
                query: {
                    presets: ['es2015']
                }
            },
            {
                test: /\.vue$/,
                loader: 'vue'
            },
            {
                test: /\.(jpe?g|png|gif)$/i,
                loaders: ['url?limit=8000&name=img/[name].[ext]']
            },
            {
                test: /\.(svg|woff|ttf|eot)$/i,
                loaders: [
                    'file-loader?name=font/[name].[ext]'
                ]
            },
            {
                test: /\.(mp3|wav)$/,
                loader: "file-loader?name=audio/[name].[ext]"
            }
        ],
        resolve: {
            root: path.resolve(__dirname, 'src'),
            modulesDirectorie: ['node_modules'],
            extensions: ['', '.js', '.css', '.scss', '.png', '.jpg', 'gif']
        }
    },
    vue: {
        postcss: [
            require('autoprefixer')({browsers: ['> 1%', 'last 2 versions', 'iOS 7']})
        ]
    },
    postcss: [
        require('autoprefixer')({browsers: ['> 1%', 'last 2 versions', 'iOS 7']})
    ],
    plugins: [
        // new webpack.optimize.CommonsChunkPlugin({
        //     'name': 'common',
        //     'filename': 'js/common.js',
        //     'minChunks' : 10,
        // }),
    ],
    externals: {
        'vue': 'Vue',
        'vue-router': 'VueRouter',
        'vue-resource': 'VueResource',
        'vue-i18n': 'VueI18n',
        'moment': 'moment',
        'lodash': '_',
        'bignumber.js': 'BigNumber',
        'particlesJS': 'particlesJS'
    }
}
